export interface NotifyFetch {
	success: number
	has_new: number
	notifys: NotifyVO[]
	data: {
		count: number
		has_new: number
		notifys: NotifyVO[]
	}
}

export interface NotifyVO {
	moid: string
	alert_state: number
	context: string
	created_at: string
	read_state: number
	source: string
	title: string
	type: 'SMC_APPLY_NOPASS' | 'SMC_APPLY_PASS' | 'SAC_ALARM'
	updated_at: string
}

export interface NotifyModel {
	data?: NotifyModel[]
	moid: string
	// 提醒状态 0未提醒 1已提醒
	alertState?: number
	// 数据
	context?: string
	// 创建时间
	createdAt?: string
	// 阅读状态 0未读 1已读
	readState?: number
	// 来源
	source?: string
	// 标题
	title: string
	// 消息类型
	type: 'SMC_APPLY_NOPASS' | 'SMC_APPLY_PASS' | 'SAC_ALARM'
	// 更新时间
	updatedAt?: string
}
const notifyTypeMap = {
	NEW_REPLY: { desc: '回复了你', url: '/comments' },
	NEW_REMINDME: { desc: '@了你', url: '/atme' },
	NEW_FAN: { desc: '关注了你', url: '/user/fans' },
	GROUP_INVITE: { desc: '邀请你加入', url: '/user/beinvited/groups' },
	NEW_LIKE: { desc: '赞了你的消息', url: '/likeme' },
	CREATE_MEETING: { desc: '邀请你参加会议：', url: '/' },
	CREATE_REGULAR: { desc: '邀请你参加例会：', url: '/' },
	NORMAL_START_FAIL_CAUSE_OF_LACK_OF_RES: {
		desc: '虚拟会议室资源不足，召开失败',
		url: '/',
	},
	NORMAL_START_FAIL_CAUSE_OF_NACK_FROM_CSS: {
		desc: '当前没有空闲的会议资源召开失败',
		url: '/',
	},
}

export function transNoticeType(notifys: NotifyVO[]): NotifyModel[] {
	return notifys.map((notify: NotifyVO) => {
		return {
			moid: notify.moid,
			alertState: notify.alert_state,
			context: notify.context,
			createdAt: notify.created_at,
			readState: notify.read_state,
			source: notify.source,
			title: notify.title,
			type: notify.type,
			updatedAt: notify.updated_at,
		}
	})
}
